package com.sustcoder.blog.Blog09;

import com.sustcoder.blog.Blog09.model.Bean1;
import com.sustcoder.blog.Blog09.model.Bean2;
import com.sustcoder.blog.Blog09.model.Bean3;
import org.apache.commons.beanutils.BeanUtils;

import java.math.BigInteger;

/**
 * Created by lenovo on 2017/10/13.
 */
public class ObjCopy {
    public static void main(String[] args) {

        Bean1 bean1=new Bean1();
        bean1.setName("name");
        bean1.setId(new BigInteger("111111"));
        Bean2 bean2=new Bean2();
        bean2.setBean1(bean1);
        bean2.setMeassage("message");
        Bean3 bean3=new Bean3();

        try{
            BeanUtils.copyProperties(bean3,bean2);
            BeanUtils.copyProperties(bean3,bean2.getBean1());
        }catch(Exception e){
            e.printStackTrace();
        }

        System.out.println(bean3.getName());
        System.out.println(bean3.getMeassage());

    }
}
